Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move sObject Refresh command to apex module and improve telemetry #1236

Merged
merged 12 commits into from
Apr 11, 2019

Conversation

brpowell
Copy link
Contributor

@brpowell brpowell commented Apr 5, 2019

What does this PR do?

The command code has been moved to the apex module, and it now kicks off the process once the language server has finished indexing the classes. This is to minimize the language server initialization clashing with pulling down all of the classes. The setting to enable or disable refresh on start is still present, but it is now under the apex configuration. Send additional telemetry data about the refresh process.

What issues does this PR fix or reference?

W-6017035

@codecov
Copy link

codecov bot commented Apr 5, 2019

Codecov Report

Merging #1236 into develop will increase coverage by 0.04%.
The diff coverage is 89.65%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1236      +/-   ##
===========================================
+ Coverage    70.93%   70.98%   +0.04%     
===========================================
  Files          198      198              
  Lines         7469     7471       +2     
  Branches       787      786       -1     
===========================================
+ Hits          5298     5303       +5     
+ Misses        2013     2010       -3     
  Partials       158      158
Impacted Files Coverage Δ
...rcedx-vscode-core/src/settings/sfdxCoreSettings.ts 60% <ø> (+3.75%) ⬆️
...code-apex/src/commands/forceGenerateFauxClasses.ts 88.33% <100%> (ø)
...faux-generator/src/generator/fauxClassGenerator.ts 90.67% <82.35%> (-0.07%) ⬇️
...forcedx-vscode-core/src/channels/channelService.ts 83.33% <0%> (-2.39%) ⬇️
...edx-vscode-core/src/telemetry/telemetryReporter.ts 53.52% <0%> (+2.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9049c0...00a53fd. Read the comment docs.

colorizer_statusbar_hover_text: 'Highlight Apex Code Coverage'
colorizer_statusbar_hover_text: 'Highlight Apex Code Coverage',
force_sobjects_no_refresh_if_already_active_error_text:
'A refresh of your sObject definitions is already underway. If you need to restart the process, cancel the running task.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@praksb
Copy link
Contributor

praksb commented Apr 8, 2019

@brpowell Is it possible to make the change to fetch the files before we start indexing in LSP? Otherwise this change would be a potential source of performance issue since I think an sobject fetch would cause us to reinitialize again. So we would have to run index once at startup and again on an sobject fetch.

@brpowell
Copy link
Contributor Author

brpowell commented Apr 8, 2019

@brpowell Is it possible to make the change to fetch the files before we start indexing in LSP? Otherwise this change would be a potential source of performance issue since I think an sobject fetch would cause us to reinitialize again. So we would have to run index once at startup and again on an sobject fetch.

You mean wait for sObject refresh to be done and then initialize the LSP? Or kick it off in parallel? If it's the former I'd say that might be a burden for the user to have to wait for refresh to finish to start using lsp features.

@lcampos
Copy link
Contributor

lcampos commented Apr 8, 2019

@praksb @brpowell indexing and recompilations are good things to look out for with these changes. Keep in mind that we don't know how long the fetching of sobjects will take since that'll depend on the org's shape. You can look at existing telemetry to get an idea, but it could be that indexing local code finishes before the sobject fetch call.

@praksb
Copy link
Contributor

praksb commented Apr 8, 2019

@brpowell I was thinking of the former (wait for sobject refresh to be done not run in parallel). But, I do see your point that the refresh might take a while. We can check this in as is and wait for customer feedback. The possible perf impact should also be minimal since we do a refresh only once now and that too only when the folder didn't exist.

@brpowell Is it possible to make the change to fetch the files before we start indexing in LSP? Otherwise this change would be a potential source of performance issue since I think an sobject fetch would cause us to reinitialize again. So we would have to run index once at startup and again on an sobject fetch.

You mean wait for sObject refresh to be done and then initialize the LSP? Or kick it off in parallel? If it's the former I'd say that might be a burden for the user to have to wait for refresh to finish to start using lsp features.

@@ -24,6 +24,21 @@ export interface CancellationToken {
isCancellationRequested: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file are for improving telemetry data around this command

"type": [
"boolean"
],
"default": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed this morning, the default behavior will now be off. The PR is mostly focused on moving the code to the apex extension and improving telemetry data now.

console.log('Generate success ' + result.data);
this.logMetric(commandName, startTime, result.data);
} catch (result) {
console.log('Generate error ' + result.error);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now log errors and successes with the number of objects fetched - if the command got far enough to collect that information.

@@ -59,14 +67,10 @@ export async function activate(context: vscode.ExtensionContext) {
}

// Telemetry
if (sfdxCoreExtension && sfdxCoreExtension.exports) {
sfdxCoreExtension.exports.telemetryService.showTelemetryMessage();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lcampos removed the telemetry message based on our discussion

@@ -205,6 +206,10 @@
{
"command": "sfdx.force.apex.test.last.method.run",
"title": "%force_apex_test_last_method_run_text%"
},
{
"command": "sfdx.force.internal.refreshsobjects",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing porting the command under commandPalette.

@@ -79,6 +87,29 @@ export class TelemetryService {
}
}

public sendErrorEvent(
error: { message: string; stack?: string },
additionalData?: any,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think commandName can be sent as part of additionalData.

Also, is it work deleting the sendError error method and update the code to use the new sendErrorEvent ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean sendError in the core module? It has quite a few references, but not a ridiculous amount. I will create separate work for it. I'll modify additionalData though 👍

@brpowell brpowell changed the title sObject Refresh on extension activation is now on by default Move sObject Refresh command to apex module and improve telemetry Apr 10, 2019
Copy link
Contributor

@lcampos lcampos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants